<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Set the external attributes of an entry defined by its name</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="ziparchive.setexternalattributesindex.html">« ZipArchive::setExternalAttributesIndex</a></li>
      <li style="float: right;"><a href="ziparchive.setmtimeindex.html">ZipArchive::setMtimeIndex »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.ziparchive.html">ZipArchive</a></li>
    <li>Set the external attributes of an entry defined by its name</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="ziparchive.setexternalattributesname" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ZipArchive::setExternalAttributesName</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.6.0, PHP 7, PHP 8, PECL zip &gt;= 1.12.4)</p><p class="refpurpose"><span class="refname">ZipArchive::setExternalAttributesName</span> &mdash; <span class="dc-title">Set the external attributes of an entry defined by its name</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-ziparchive.setexternalattributesname-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>ZipArchive::setExternalAttributesName</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">string</span> <code class="parameter">$name</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">int</span> <code class="parameter">$opsys</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">int</span> <code class="parameter">$attr</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">int</span> <code class="parameter">$flags</code><span class="initializer"> = 0</span></span><br>): <span class="type">bool</span></div>

  <p class="para rdfs-comment">
   Set the external attributes of an entry defined by its name.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-ziparchive.setexternalattributesname-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">name</code></dt>

     <dd>

      <p class="para">
       Name of the entry.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">opsys</code></dt>

     <dd>

      <p class="para">
       The operating system code defined by one of the ZipArchive::OPSYS_ constants.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">attr</code></dt>

     <dd>

      <p class="para">
       The external attributes. Value depends on operating system.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">flags</code></dt>

     <dd>

      <p class="para">
       Optional flags. Currently unused.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-ziparchive.setexternalattributesname-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>true</code></strong>， 或者在失败时返回 <strong><code>false</code></strong>。
  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-ziparchive.setexternalattributesname-examples">
  <h3 class="title">范例</h3>
    <p class="para">
     This example opens a ZIP file archive
     <var class="filename">test.zip</var> and add
     the file <var class="filename">test.txt</var>
     with its Unix rights as external attributes.
    </p>
    <div class="example" id="example-869">
     <p><strong>示例 #1 Archive a file, with its Unix rights</strong></p>
     <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$zip&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">ZipArchive</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$stat&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">stat</span><span style="color: #007700">(</span><span style="color: #0000BB">$filename</span><span style="color: #007700">=</span><span style="color: #DD0000">'test.txt'</span><span style="color: #007700">);<br />if&nbsp;(</span><span style="color: #0000BB">is_array</span><span style="color: #007700">(</span><span style="color: #0000BB">$stat</span><span style="color: #007700">)&nbsp;&amp;&amp;&nbsp;</span><span style="color: #0000BB">$zip</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">open</span><span style="color: #007700">(</span><span style="color: #DD0000">'test.zip'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">ZipArchive</span><span style="color: #007700">::</span><span style="color: #0000BB">CREATE</span><span style="color: #007700">)&nbsp;===&nbsp;</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$zip</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">addFile</span><span style="color: #007700">(</span><span style="color: #0000BB">$filename</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$zip</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setExternalAttributesName</span><span style="color: #007700">(</span><span style="color: #0000BB">$filename</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">ZipArchive</span><span style="color: #007700">::</span><span style="color: #0000BB">OPSYS_UNIX</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$stat</span><span style="color: #007700">[</span><span style="color: #DD0000">'mode'</span><span style="color: #007700">]&nbsp;&lt;&lt;&nbsp;</span><span style="color: #0000BB">16</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$zip</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">close</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Ok\n"</span><span style="color: #007700">;<br />}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"KO\n"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
     </div>

    </div>
 </div>

</div></div></div></body></html>